package com.ruoyi.service.traceability.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.traceability.MesTraceabilityDetailMapper;
import com.ruoyi.domain.traceability.MesTraceabilityDetail;
import com.ruoyi.service.traceability.IMesTraceabilityDetailService;

/**
 * 追溯详情Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
@Service
public class MesTraceabilityDetailServiceImpl implements IMesTraceabilityDetailService {
    @Autowired
    private MesTraceabilityDetailMapper mesTraceabilityDetailMapper;

    /**
     * 查询追溯详情
     * 
     * @param detailId 追溯详情主键
     * @return 追溯详情
     */
    @Override
    public MesTraceabilityDetail selectMesTraceabilityDetailByDetailId(Long detailId) {
        return mesTraceabilityDetailMapper.selectMesTraceabilityDetailByDetailId(detailId);
    }

    /**
     * 查询追溯详情列表
     * 
     * @param mesTraceabilityDetail 追溯详情
     * @return 追溯详情
     */
    @Override
    public List<MesTraceabilityDetail> selectMesTraceabilityDetailList(MesTraceabilityDetail mesTraceabilityDetail) {
        return mesTraceabilityDetailMapper.selectMesTraceabilityDetailList(mesTraceabilityDetail);
    }

    /**
     * 新增追溯详情
     * 
     * @param mesTraceabilityDetail 追溯详情
     * @return 结果
     */
    @Override
    public int insertMesTraceabilityDetail(MesTraceabilityDetail mesTraceabilityDetail) {
        mesTraceabilityDetail.setCreateTime(DateUtils.getNowDate());
        return mesTraceabilityDetailMapper.insertMesTraceabilityDetail(mesTraceabilityDetail);
    }

    /**
     * 修改追溯详情
     * 
     * @param mesTraceabilityDetail 追溯详情
     * @return 结果
     */
    @Override
    public int updateMesTraceabilityDetail(MesTraceabilityDetail mesTraceabilityDetail) {
        mesTraceabilityDetail.setUpdateTime(DateUtils.getNowDate());
        return mesTraceabilityDetailMapper.updateMesTraceabilityDetail(mesTraceabilityDetail);
    }

    /**
     * 批量删除追溯详情
     * 
     * @param detailIds 需要删除的追溯详情主键
     * @return 结果
     */
    @Override
    public int deleteMesTraceabilityDetailByDetailIds(Long[] detailIds) {
        return mesTraceabilityDetailMapper.deleteMesTraceabilityDetailByDetailIds(detailIds);
    }

    /**
     * 删除追溯详情信息
     * 
     * @param detailId 追溯详情主键
     * @return 结果
     */
    @Override
    public int deleteMesTraceabilityDetailByDetailId(Long detailId) {
        return mesTraceabilityDetailMapper.deleteMesTraceabilityDetailByDetailId(detailId);
    }

    /**
     * 根据追溯记录ID查询详情列表
     * 
     * @param traceId 追溯记录ID
     * @return 追溯详情列表
     */
    @Override
    public List<MesTraceabilityDetail> selectDetailsByTraceId(Long traceId) {
        return mesTraceabilityDetailMapper.selectDetailsByTraceId(traceId);
    }

    /**
     * 根据父节点ID查询子节点列表
     * 
     * @param parentNodeId 父节点ID
     * @return 追溯详情列表
     */
    @Override
    public List<MesTraceabilityDetail> selectDetailsByParentNodeId(Long parentNodeId) {
        return mesTraceabilityDetailMapper.selectDetailsByParentNodeId(parentNodeId);
    }

    /**
     * 根据节点类型查询详情列表
     * 
     * @param nodeType 节点类型
     * @return 追溯详情列表
     */
    @Override
    public List<MesTraceabilityDetail> selectDetailsByNodeType(String nodeType) {
        return mesTraceabilityDetailMapper.selectDetailsByNodeType(nodeType);
    }

    /**
     * 批量插入追溯详情
     * 
     * @param traceabilityDetails 追溯详情列表
     * @return 结果
     */
    @Override
    public int batchInsertTraceabilityDetail(List<MesTraceabilityDetail> traceabilityDetails) {
        return mesTraceabilityDetailMapper.batchInsertTraceabilityDetail(traceabilityDetails);
    }

    /**
     * 根据追溯记录ID删除所有详情
     * 
     * @param traceId 追溯记录ID
     * @return 结果
     */
    @Override
    public int deleteDetailsByTraceId(Long traceId) {
        return mesTraceabilityDetailMapper.deleteDetailsByTraceId(traceId);
    }
}